/* CUC Online Judge - A cross-platform judge online system
 * Base on [Verwandlung Online Judge](https://github.com/hzxie/voj)
 * Copyright (C) 2021 Jinhe Zhang <307100890@qq.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *                             /\/`\/\
 *                            _\ | | /_
 *                          -           -
 *                        /               \
 *                       | |-------------| |
 *                       | |^=-_#   #_-=^| |
 *                       \/ \O__/,_ \O__/ \/
 *                        \  \\\     \\\  /
 *                         _\     o     /_
 *                        |/ `--=___=--` \|
 *                       /              六 \
 *                      |  ____       __七_ |
 *                       \____/_\   /_\____/
 */
package org.verwandlung.voj.web.model;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 用户的Model.
 * 对应数据库中的voj_classes数据表.
 * 
 * @author Haozhe Xie
 */
public class Student implements Serializable {
	/**
	 * 用户的默认构造函数. 
	 */
	public Student() { }
	
	/**
	 * ClassC的构造函数.
	 * @param studentName - 学生姓名
	 * @param studentCode - 学号
	 * @param classC - 班级标识
	 */
	public Student(String studentName, String studentCode, ClassC classC) {
		this.studentName = studentName;
		this.studentCode = studentCode;
		this.classC = classC;
	}
	
	/**
	 * ClassC类的构造函数.
	 * @param stuid - 学生唯一标识符
	 * @param studentName - 学生姓名
	 * @param studentCode - 学号
	 * @param classC - 班级标识
	 */
	public Student(int stuid, String studentName, String studentCode, ClassC classC) {
		this(studentName, studentCode, classC);
		this.stuid = stuid;
	}

	/**
	 * 获取用户名.
	 * @return 用户名
	 */
	public String getStudentName() {
		return studentName;
	}
	public String getStudentCode() {
		return studentCode;
	}
	public ClassC getClassC() {
		return classC;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return (int) stuid;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if ( obj instanceof Student ) {
			Student anotherUser = (Student)obj;
			return anotherUser.getStuid() == stuid;
		}
		return false;
	}

	public long getStuid() {
		return stuid;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return String.format("Class: [stuid=%s, studentName=%s, studentCode=%s, classC=%s]", new Object[] { stuid, studentName, studentCode, classC });
	}
	
	private long stuid;
	private String studentName;
	private String studentCode;
	@JsonIgnore
	private ClassC classC;

	/**
	 * 唯一的序列化标识符.
	 */
	private static final long serialVersionUID = 2264535351943252509L;
}
